import java.text.DateFormat;

public class 简单工厂 {
    public static Product createProduct(String type) {
        if (type.equals("a")) {
            return new ProductA();
        } else if (type.equals("b")) {
            return new ProductB();
        } else {
            return null;
        }
    }


    public static void main(String[] args) {
        Product p = 简单工厂.createProduct("a");
        p.show();

    }
}
abstract class Product {
    abstract void show();
}
class ProductA extends Product{
    void show() {
        System.out.println("productA");
    }
}
class ProductB extends Product{
    void show() {
        System.out.println("productB");
    }
}